
#  用户操作类型对照表

OPERATE = {
    "start_vm": "虚拟机开机",
    "stop_vm": "虚拟机关机",
    "create_l2_vxlan_network_pool": "新建场景",
    "create_vni_range": "新建场景",
    "attach_l2_network_to_cluster": "新建场景",
    "create_l2_vxlan_network": "新建场景",
    "create_l3_network": "新建交换机",
    "attach_network_service_to_l3Network": "新建交换机",
    "create_l3_network_ip_ranges": "新建交换机",
    "add_dns_to_l3_network": "新建交换机",
    "create_vpc_router": "新建路由器",
    "create_vm": "新建虚拟机",
    "del_vm_destroy": "删除虚拟机",
    "del_vm_expunge": "删除虚拟机",
    "attach_l3network_route": "交换机与路由器连接",
    "del_l3_network": "删除交换机",
    "del_vm_nic": "删除交换机与路由器连接",
    "detach_l3_network_vm": "删除交换机与虚拟机连接",
    "del_router": "删除路由器",
    "create_vip_action": "新建虚拟机-入口",
    "create_eip_action": "新建虚拟机-入口",
    "attach_eip_to_vm": "新建虚拟机-入口",
    "create_port_mirror_session": "新建审计",
    "create_image": "上传镜像",
    "del_image_expunge": "删除镜像",
    "del_image_destroy": "删除镜像",
    "create_security_group": "创建安全组",
    "del_security_group": "删除安全组",
    "attach_security_group_rule": "创建安全组规则",
    "del_security_group_rule": "删除安全组规则",
    "attach_vm_nic_security_group": "关联安全组",
    "attach_security_group_l3_network": "关联安全组",
    "add_stack_template": "比赛关联场景",
    "create_resource_stack": "开启环境",
    "del_stack_template": "删除比赛关联场景",
    "get_vm_console_address": "获取终端地址",
    "del_resource_stack": "删除场景",
    "del_range_database": "删除场景",
    "attach_vm_nic_vm": "加载网卡",
    "create_vm_nic": "加载网卡",
    "update_all_operate_database": "一键开机",
    "del_connect_vm_database": "删除虚拟机和交换机连接",
    "del_connect_router_database": "删除路由器和交换机连接",
    "update_all_active_operate_database": "开启环境",
    "del_vm_database": "删除虚拟机",
    "update_router_state": "新建路由器"
}

# 无关联操作， 创建、添加失败再删除

DELETE_OPERATE_TYPE = {
    "create_l2_vxlan_network_pool": "l2_network",
    "create_vni_range": "l2_network",
    "attach_l2_network_to_cluster": "l2_network",
    "create_l2_vxlan_network": "l2_network",
    "create_l3_network": "l3_network",
    "attach_network_service_to_l3Network": "l3_network",
    "create_l3_network_ip_ranges": "l3_network",
    "add_dns_to_l3_network": "l3_network",
    "create_vpc_router": "router",
    "create_vm": "vm",
    "attach_l3network_route": "l3_network_to_router",
    "create_vip_action": "eip",
    "create_eip_action": "eip",
    "attach_eip_to_vm": "eip",
    "create_port_mirror_session": "port_mirror",
    "create_image": "image",
    "create_security_group": "security_group",
    "attach_security_group_rule": "security_group",
    "attach_vm_nic_security_group": "security_group",
    "attach_security_group_l3_network": "security_group",
    "add_stack_template": "resource_stack",
    "create_resource_stack": "resource_stack"
   }

OPERATE_TYPE_DELETE_FUNCTION = {
    # "vm": ["del_vm_database", "del_vm_destroy", "del_vm_expunge"],
    "vm": {
            "db_model": "rangeModel.RangeVm", 
            "filter_field": "op_vm_uuid", 
            "on_delete": False,
            "update_data": {"op_vm_uuid": "", "op_vm_name": ""},
            "function": ["callback_database"]},
    "l3_network": {
        "db_model": "switchModel.Switchs",
        "filter_field": "subnet_id",
        "on_delete": True,
        "function": ["callback_database"]
    },
    "router": {
        "db_model": "switchModel.Routes",
        "filter_field": "op_route",
        "on_delete": True,
        "function": ["callback_database"]
    },
    "l2_network": {
        # "db_model": "rangeModel.Range"
    },
    "eip": {
        
    },
    "port_mirror": {
        
    },
    "resource_stack": {},
    "l3_network_to_router": {
        "db_model": "switchModel.Ports",
        "filter_filed": "port_id",
        "on_delete": True,
        "function": ["callback_database"]
    },
    "create_image": {}
}


# 推送白名单
skipped_push = [
    "create_l2_vxlan_network_pool", 
    "create_vni_range", 
    "attach_l2_network_to_cluster"
]


container_status_map = {
    "Creating": "BUILD",
    "Created": "BUILD",
    "Stopping": "BUILD",
    "Running": "ACTIVE",
    "Stopped": "SHUTOFF",
}